﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;

namespace HYBYSoft.Company.Models
{
    [MetadataType(typeof(Admin_Metadata))]
    public partial class Admin
    {
        [Display(Name = "确认密码"), Compare("Password", ErrorMessage = "密码不一致，请重新输入")]
        [StringLength(32, MinimumLength = 6)]
        [Required]
        public string RePassword
        { get; set; }

        [Display(Name = "旧密码")]
        [StringLength(32, MinimumLength = 6)]
        public string OldPassword
        { get; set; }

        public class Admin_Metadata
        {
            [Display(Name = "用户名")]
            [StringLength(16, MinimumLength = 2)]            
            [RegularExpression(@"^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$",ErrorMessage="用户只能输入中文、英文、数字，下划线，且不可以用下划线开头。")]
            [Remote("CheckName", "Member", ErrorMessage = "该名称已经存在，请重新输入")]            
            public string Name
            { get; set; }

            [Display(Name = "密码")]
            [Required]
            [StringLength(32, MinimumLength = 6)]
            public string Password
            { get; set; }


            [Display(Name = "创建者")]
            public string Creator
            { get; set; }

            [Display(Name = "创建时间")]
            public DateTime? CreateTime
            { get; set; }

            [Display(Name = "最后修改者")]
            public string Editor
            { get; set; }

            [Display(Name = "最后修改时间")]
            public DateTime? LastEditTime
            { get; set; }

            [Display(Name = "状态")]
            public int State
            { get; set; }
        }
    }
}
